package 栈;

import java.util.Stack;

public class Leedcode232用栈实现队列 {


    //主栈
    private Stack<Integer> s1 = new Stack<>();
    //辅助栈
    private Stack<Integer> s2 = new Stack<>();

    public Leedcode232用栈实现队列() {

    }

    public void push(int x) {
        while(!s1.isEmpty()){
            s2.push(s1.pop());
        }
        s1.push(x);
        while(!s2.isEmpty()){
            s1.push(s2.pop());
        }
    }

    public int pop() {
        return s1.pop();
    }

    public int peek() {
        return s1.peek();
    }

    public boolean empty() {
        return s1.isEmpty();
    }
}
